//
//  SoundManager.m
//  PhageWar
//
//  Created by Tran Dang Khoa on 4/16/09.
//  Copyright 2009 HCMUT. All rights reserved.
//

#import "SoundManager.h"

@implementation SoundManager

static bool enabled_ = true;
static NSMutableDictionary *tracks;

+(void) addSoundTrack:(NSString*)filename type:(NSString*)filetype name:(NSString*)name  {
	if (tracks == nil) {
		tracks = [[NSMutableDictionary alloc] init];
	}
	SoundEffect *sound = [[[SoundEffect alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:filename ofType:filetype]] autorelease];
	[tracks setObject:sound forKey:name];
}

+(void) playSoundTrack:(NSString*)name {
#ifndef DEBUG_NO_SOUND
	if(enabled_) [[tracks objectForKey:name] play];
#endif
}

+(void) setEnabled:(bool)value {
	enabled_ = value;
}
+ (bool)enabled {
	return enabled_;
}

+(void) removeSoundTrack:(NSString*)name {
	[tracks removeObjectForKey:name];
}

+(void) removeAll {
	[tracks removeAllObjects];
	[tracks release];
	tracks = nil;
}
@end
